﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Client_AboutUs : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void cmdSubmit_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            msCaptcha.ValidateCaptcha(txtCaptcha.Text);
            if (msCaptcha.UserValidated)
            {
                EmailService emailSrv = new EmailService();
                string strMessage = txtMsg.Text.Trim();
                string strMessageCustomer = txtMsg.Text.Trim();

                //Send to specified department
                emailSrv.SendContactUsEmail(txtName.Text.Trim(),
                                            txtPhone.Text.Trim(),
                                            txtEmail.Text.Trim(),
                                            Global.CONTACT_EMAIL_ADDRESS,
                                            txtSubject.Text.Trim(),
                                            strMessageCustomer,
                                            Server.MapPath(Global.CONTACT_US));
                //Send thanking email to customer
                emailSrv.SendContactUsEmail(txtName.Text.Trim(),
                                            txtPhone.Text.Trim(),
                                            "",
                                            txtEmail.Text,
                                            txtSubject.Text.Trim(),
                                            strMessageCustomer,
                                            Server.MapPath(Global.CONTACT_US_THANK_YOU));
                txtCaptcha.Text = String.Empty;

                lblMessage.Text = "Đã gửi thư. Cảm ơn bạn!";
                lblMessage.ForeColor = System.Drawing.Color.Blue;
                lblMessage.Font.Bold = true;

                pnlContactUs.Visible = false;
                txtName.Text = txtPhone.Text = txtEmail.Text = txtSubject.Text = txtMsg.Text = txtCaptcha.Text = "";
            }
            else
            {
                lblMessage.Text = "Nhập mã xác minh không chính xác";
                txtCaptcha.Text = String.Empty;
                lblMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
        catch (Exception ex)
        {
            lblMessage.Text = ex.Message;
            lblMessage.ForeColor = System.Drawing.Color.Red;
        }
    }
    protected void lnkRefreshCaptcha_Click(object sender, EventArgs e)
    {
        lblInputCaptcha.Text = string.Empty;
    }
}
